CC= gcc
LIBS=-lm 
RM=rm -rf
DEBUG=-g 
INCLUDES=include/
SRCS=server.c parser.c socket.c servHelper.c filesContent.c sql.c acsLogger.c start-stop.c
HDRS=$(SRCS:.c=.h)
OBJS=$(SRCS:.c=.o) 
LIBS+=`mysql_config --cflags --libs` 
CFLAGS=-Wall $(DEBUG)

	
all: ACS_Server
	
ACS_Server: $(OBJS)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) 

server.o: $(INCLUDES)server.h $(INCLUDES)socket.h server.c 
	$(CC) -c $(CFLAGS) server.c $(LIBS)

parser.o: $(INCLUDES)parser.h parser.c
	$(CC) -c $(CFLAGS) parser.c $(LIBS)

socket.o: $(INCLUDES)socket.h $(INCLUDES)servHelper.h socket.c
	$(CC) -c $(CFLAGS) socket.c $(LIBS)

servHelper.o: $(INCLUDES)servHelper.h  $(INCLUDES)parser.h $(INCLUDES)filesContent.h $(INCLUDES)data.h $(INCLUDES)sql.h $(INCLUDES)acsLogger.h servHelper.c 
	$(CC) -c $(CFLAGS) servHelper.c $(LIBS)

fileContent.o: $(INCLUDES)fileContent.h fileContent.c
	$(CC) -c $(CFLAGS) fileContent.c $(LIBS)

sql.o:  $(INCLUDES)sql.h sql.c
	$(CC) -c $(CFLAGS) sql.c $(LIBS)

logger.o:  $(INCLUDES)acsLogger.h acsLogger.c
	$(CC) -c $(CFLAGS) acsLogger.c $(LIBS)

start-stop.o:  $(INCLUDES)start-stop.h start-stop.c
	$(CC) -c $(CFLAGS) start-stop.c $(LIBS)
	
depend:
	makedepend $(SRCS)

tar:
	tar cf ACS_Server.tar Makefile *.c $(INCLUDES)*.h

print:
	more Makefile $(HDRS) $(SRCS) | server -2r -p

clean:
	-$(RM) *.o ACS_Server 
	

